package com.wang.config;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;


public class AlipayConfig {

    /**
     * 支付宝网关地址  TODO
     */
    public static final String PAY_GATEWAY = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";


    /**
     * 支付宝 APPID TODO
     */
    public static final String APPID = "9021000149669902";

    /**
     * 应用私钥 TODO
     */
    public static final String APP_PRI_KEY = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC3ERkHMYOoGWyNaMzKss9djjyd+8WqDLaOJbNo1Mv6gjD0tbf9hyBa50QzQrgBhAmb3D0W1FL8Vxt18xr3X+KgU+H7FjlAQh/LnAOUgmNBvdkG6CS9T7uSLHPGiqyqCH9RbtyA+gsOOAKLv0lwqhF+SoM6ZgXj5bVx97PzViLCGq+PIgbiAKIOEi98uxBKXB4ffs0z8e5qIIY4XkXguUNwzQvhJX8o8HemAwofSHSIdiFEXDlRrI7HEVPT5t9hj/JnK5BhAX67sQH4y72gIAfZQMVbhCyHFvjSnqwfPbnzQNa38K8h22/a9r2ulGzAKJSDx7dMNGReCzhoqhKOo8jPAgMBAAECggEAEDcefWmgXMpruBbZVPcDsSjBK8k6V/aqUOr7+kQnETho97QE6RsH/aVQgC3fuJqmczzN2HDULO/WSdtPvyuqGkNz19a/GXcB8/oMwyHNguw7BgaYAoDGf4sacjKkWqdIB8GHHJGJWygQ6an26ljWFdapywlwaiBVsxOax+oQSBsIqdDwo5uCIvltm0IVn8F3l9fTEV/TE9vPSCTUAWV+mEPk5G+hf62IeeoE0HFS2nFafnDpi942Srday8Y8dflEGt25dXOjgvHCurHkUwun7GT1pCFd8SZWIigrRA1f0leRn0cBg5IlXLiXAVb0Hp2DSs15W9B9FOHWd2bYbpgykQKBgQDZ9PyvES7oZyPUhiiYBsjWqyVXFZhtYCCF0A5zHyJHLpfcqrH1HxkXhIZ+9NWDVwtBanF/FjAWQj7NT/z+Qml2K4+MgHdGXRzm8wnP0lvzQN13utymj4Z8jLLB4mv6M9Y0QlkMP/qUWyTLTBWcs5DicxIIvjoYCdoh4jAf713MeQKBgQDXBRsMNE1ZOnboOqHHE9rtFIB+ZovCDmo7akqc5nq3vOqPd99dyujJxkQbkpteZQyivOGZboU9VwSk+44kJPCA5tAVM1ryW295EUjJHYsmGcg/EhQ59cnCPOltP6hYQfqqn+aKSxJXKUxWDby1bo3/ZxFQeg0iJytW8diMpM1dhwKBgQC5uWXcNBM5nDHO9ib/LMDVE+90noVNplzwSZMWjBAkgdKMCbQswLwb6yTEaBLMoU6JBpACEEEXpolnYGKfsq21MXdX7Vw1zEBFmBHjUkhiJwLQ9JzzHVgnJ6lnR25lPOipjWPd6WK4KlZXGdVMu0KZhB547sgIFdUXjGsfu1O9WQKBgQCLTbB/UKdIBrugqtPC4Vc1v9Gbkp47BBHJGozqZ9vbjBY/Cr94yYvVpZDceDgWiMsN5+cU+2hxHB5TMPKe8huqt17aTWI/oANxYURRn8VV0uBMFE9sWZP0NnhYoiRTwbM/tcarlAV22LevDMlUliKC9GhgRiKaHNxUQO01+VNfowKBgQCrdLfKMjrYzJ8YT+LzyzAx84ugrPpl057+PQUfaFgqOadDVQTfet6cxtlaU5okm2A1Sn312hF+MFxmlri2TuT7y3kRDfP/Vs5oekuwMJtnnkuUW4LaSfrwpxHIt46fWcuVexr/PMst79KHU+3zNKl7XBcYo8lO0rNIO45FVYo77w==";
    /**
     * 支付宝公钥 TODO
     */
    public static final String ALIPAY_PUB_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmXQL2a2mD3/O6ywF08wZAfchw2FhNG658+DlE8zurQ7AkO7Sn9KIPCCVaDpcRUyGI4y0env9vuhozm1jWp5xckuzjmuRoNk5x8naTC98ZWCQvZcmOMHS6XBAPhV0WdclZqyCBKX62JZgf1CHEGK8JMmHDfjxRLeIJwEiNqTlay7uQhDFD8hD06gDW/hhltjfSwyt7MYkpjladdC7J7FqZpyrJtEJD3RprKsMG4vEg1L+QdGP9W3JvsAdEznmBGpB3TJcMsL6XCusikmxQqPAEjeF1++Ft+nLELFj4WqgiylvLP5gSGW5/YzX2brZUXMaLSWJF25IBqxcIPr1sNzAgwIDAQAB";

    /**
     * 签名类型
     */
    public static final String SIGN_TYPE = "RSA2";


    /**
     * 字符编码
     */
    public static final String CHARSET = "UTF-8";


    /**
     * 返回参数格式
     */
    public static final String FORMAT = "json";

    private volatile static AlipayClient instance = null;
    /**
     * 构造函数私有化   ——————单例设计模式  实现  步骤之一
     */
    private AlipayConfig() {
    }

    /**
     * 单例设计模式  ———— 懒汉式     双重锁校验
     * @return
     */
    public static AlipayClient getInstance(){
        if(instance == null){
            synchronized (AlipayConfig.class){
                if(instance == null){
                    instance = new DefaultAlipayClient(PAY_GATEWAY,APPID,APP_PRI_KEY,FORMAT,CHARSET,ALIPAY_PUB_KEY,SIGN_TYPE);
                }
            }
        }
        return instance;
    }
}
